package org.tity.test.dao.transaction;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value="/dao/transaction")
public class TransactionController {
 
	@Autowired
	private TransactionService service;
	
	@RequestMapping(value="/t1")
	public String t1() {
		//使用 transactionExecute 事务
		service.t1();
		return "ok";
	}
	
	@RequestMapping(value="/t2")
	public String t2() {
		//@Transactional 注解
		service.t2();
		return "ok";
	}
	
	@RequestMapping(value="/t3")
	public String t3() {
		service.t3();
		return "ok";
	}
	
	@RequestMapping(value="/t4")
	public String t4() {
		service.t4();
		return "ok";
	}
	
	@RequestMapping(value="/t5")
	public String t5(int act) {
		service.t5(act);
		return "ok";
	}
	
	@RequestMapping(value="/te1")
	public String te1(String type) throws Exception {
		service.te1(type);
		return "ok";
	}
	
	@RequestMapping(value="/te2")
	public String te2(String type) throws Exception {
		service.te2(type);
		return "ok";
	}
	
}
